package cn.tedu._04mybatis.mapper;

import cn.tedu._04mybatis.pojo.entity.Comment;
import cn.tedu._04mybatis.pojo.vo.CommentVO3;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface CommentMapper {
    @Insert("INSERT INTO comment (content,created,user_id,weibo_id) VALUES " +
            "(#{content},#{created},#{userId},#{weiboId})")
    int insertComment(Comment comment);

    @Delete("DELETE FROM comment WHERE id = #{id}")
    int deleteById(Long id);

    @Select("SELECT content,user_id AS userId,weibo_id AS weiboId FROM comment WHERE id = #{id}")
    List<Comment> selectCommentById1(Long id);

    @Select("SELECT content,user_id AS userId FROM comment WHERE user_id = #{uid}")
    List<Comment> selectCommentById2(Long uid);

    /**
     * ResultMap小练习
     */

    List<CommentVO3> selectComment(Long id);


}
